

import 'package:get/get.dart';
import 'package:video_player/video_player.dart';

class VideoController extends GetxController{

  var isPlaying = false.obs;
  late VideoPlayerController videoPlayerController;

  VideoController(String videoUrl) {
    videoPlayerController = VideoPlayerController.networkUrl(Uri.parse(videoUrl));
  }

  void play() {
    if (!isPlaying.value) {
      videoPlayerController.play();
      isPlaying.value = true;
    }
  }

  void pause() {
    if (isPlaying.value) {
      videoPlayerController.pause();
      isPlaying.value = false;
    }
  }

  void stop() {
    videoPlayerController.pause();
    videoPlayerController.seekTo(Duration.zero);
    isPlaying.value = false;
  }

  @override
  void onClose() {
    videoPlayerController.dispose();
    super.onClose();
  }

}